<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc"%>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		var stopReason = document.getElementById("stopReason");
		if(stopReason.value == ""){
			alert("撤消原因<fmt:message key='common.message.empty'/>");
			return false;
		}
		return true;
	}

	function back(){
		var uri = "./contract.do?action=preWaitAduitContract";
		var sign = "<c:out value='${sign}'/>";
		if(sign == "1"){//返回到待审合同页面
			uri = "./contract.do?action=preWaitAduitContract";
		}else if(sign == "2"){//返回到退回合同页面
			uri = "./contract.do?action=preReturnContract";
		}
		window.location.href = uri;
		window.location.target = "main";
	}
	
	function deleteAdded(){
		var currentValue = document.all.addedId.value;
		if(currentValue != ""){
			document.cancelContractForm.action = "./contract.do?action=deleteCancelContractAdded&addedId="+currentValue;
			document.cancelContractForm.target = "main";
			document.cancelContractForm.submit();
		}else{
			alert("请选择要删除的附件！");
		}
	}
	
	function save(){
		if(checkForm()){
			document.cancelContractForm.action = "./contract.do?action=cancelContractByWaitAudit";
			document.cancelContractForm.target = "main";
			document.cancelContractForm.submit();
			
			document.getElementById("saveBtn").href = "#";
		}
	}
	
	function initPage(){
		if("<c:out value='${uploadResult}'/>" == 3){
			alert("终止失败：上传文件大小不能超过10M!");
		}else if("<c:out value='${uploadResult}'/>" == 4){
			alert("终止失败：请勿重复上传附件!");
		}
		if("<c:out value='${deleteResult}'/>" == 1){
			alert("删除附件成功！");
		}
		
		document.getElementById("saveBtn").href = "javascript:save();";
	}
-->
</script>
</head>
<body onload="initPage()">
<form name="cancelContractForm" action="" method="post" enctype="multipart/form-data">
	<a class="common_title">>> 您现在的位置：营销财务 >> 撤消合同</a>
	
	<div class="tools">
		<a id="saveBtn" name="saveBtn" class="save" href="javascript:save();" title="提交" hidefocus="true">提交</a>&nbsp;&nbsp;&nbsp;&nbsp;
		<a class="back" href="javascript:back();" title="返回" hidefocus="true">返回</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	</div>	
	
	<table class="table_input1">
		<tr>
			<td>
				<table class="table" cellpadding="0" cellspacing="0" style="margin: 10px 0 10px 50px;width: 800px;">
					<tr>
						<td class="title3" width="100">客户名称：</td>
						<td class="title3">
							${contract.customerName}
							<input id="customerId" name="customerId" type="hidden" value="${contract.customerId}"/>
						</td>
						<td width="100"></td>
						<td class="title3" width="100">合同名称：</td>
						<td class="title3">
							${contract.contractName}
							<input id="id" name="id" type="hidden" value="${contract.id}"/>
						</td>
					</tr>
					<tr>
						<td class="title3" width="">合同编号：</td>
						<td class="title3">${contract.contractCode}</td>
						<td width="100"></td>
						<td class="title3" width="">销售代表：</td>
						<td class="title3">${contract.salePerson}</td>
					</tr>
					<tr>
						<td class="title3" width="">审核人：</td>
						<td class="title3">${contract.auditPerson}</td>
						<td width="100"></td>
						<td class="title3" width="">审核日期：</td>
						<td class="title3"><fmt:formatDate value="${contract.auditDate}" pattern="yyyy-MM-dd"/></td>
					</tr>
					<tr>
						<td class="" width="">备注：</td>
						<td class="" colspan="4"><pre>${contract.contractDesc}</pre></td>
					</tr>
					<tr>
						<td class="title3" width="">撤消原因：</td>
						<td class="title3" colspan="4"><textarea id="stopReason" name="stopReason" class="textarea_style1" wrap="hard">${contract.stopReason}</textarea></td>
					</tr>
					<tr>
						<td class="title3" rowspan="2" style="height: 60px;">附件：</td>
						<td class="title3" colspan="4">
							<select id="addedId" name="addedId" style="width: 86%">
								<c:forEach var="systemFile" items="${contractAddeds}">
								<option value="${systemFile.id}">附件名称：${systemFile.fileName}，上传者：${systemFile.person}，上传时间：<fmt:formatDate value="${systemFile.uploadDate}" pattern="yyyy-MM-dd"/></option>
								</c:forEach>
							</select>&nbsp;
							<input class="btn1" type="button" value=" 删 除 " onclick="deleteAdded()">
						</td>
					</tr>
					<tr>
						<td class="title3" colspan="5">
							<input id="contents" name="contents" type="file" style="width: 96%"/>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	
	<table class="table_style" style="text-align: center;">
		<tr>
			<td class="title4">采购内容</td>
			<td class="title4" width="8%">单位</td>
			<td class="title4" width="12%">单价(元)</td>
			<td class="title4" width="8%">数量</td>
			<td class="title4" width="12%">折扣率(%)</td>
			<td class="title4" width="12%">折扣后的金额(元)</td>
			<td class="title4" width="12%">成本(元)</td>
			<td class="title4" width="12%">毛利(元)</td>
		</tr>
		<c:forEach var="contractDetail" items="${contractDetails}">
		<tr>
			<td>${contractDetail.purchaseDesc}</td>
			<td>${contractDetail.unit}</td>
			<td>${contractDetail.price}</td>
			<td>${contractDetail.num}</td>
			<td>${contractDetail.discount}</td>
			<td>${contractDetail.costValue}</td>
			<td>${contractDetail.costs}</td>
			<td>${contractDetail.prossProfit}</td>
		</tr>
		</c:forEach>
	</table>
	<input id="sign" name="sign" type="hidden" value="${sign}"/>
</form>
</body>
</html>